package com.example.multiple.service;

import com.example.multiple.domain.master.Log;
import com.example.multiple.domain.slave.Logger;
import com.example.multiple.mapper.master.MasterMapper;
import com.example.multiple.mapper.slave.SlaveMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DatasourceService {

    @Resource
    private MasterMapper masterMapper;

    @Resource
    private SlaveMapper slaveMapper;

    @Transactional(rollbackFor = Exception.class)
    public void handle(){
        Log log = new Log();
        log.setContent("主数据源");
        masterMapper.insert(log);
        Logger logger = new Logger();
        logger.setContent("从数据库源");
        slaveMapper.insert(logger);
        int a = 1/0;
    }
}
